package org.gd.hellojaxb.privat24.registration;

import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.sql.SQLException;

@XmlRootElement(name = "state")
@XmlAccessorType(XmlAccessType.NONE)
public class State {

    /**
     * ecom statusCode
     */
    @XmlElement
    private int ecom_c1 = -1;
    /**
     * ecom reason code
     */
    @XmlElement
    private int ecom_c2 = -1;
    /**
     * сколько клиентов найдено
     */
    @XmlElement
    private int clients = -1;
    /**
     * 10-регистрация,
     * 20-смена пароля,
     * 30-отправка ОТП,
     * 31-проверка ОТП,
     * 50 - ввод инн
     */
    @XmlElement
    private int arm = -1;
    /**
     * 0-ошибка,
     * 10-зарегистрировался,
     * 20-сменил пароль и разблокировался,
     * 21 сменил пароль, но не разблокировался,
     * 30-отп отправлено,
     * 31-отп проверено
     */
    @XmlElement
    private int state = 0;
    /**
     * 10-ошибка eccommerce,
     * 20-ошибка ЕКБ,
     * 30-ошибка П48,
     * 40- ошибка пинблока,
     * 50- ошибка при отправке отп,
     * 51- ошибка при проверке отп
     */
    @XmlElement
    private int ext_complex_state = -1;

    @XmlAttribute
    @XmlJavaTypeAdapter(NullStringXmlAdapter.class)
    private String phone = null;
    @XmlElement
    private String inn = null;
    @XmlElement
    private String ip = null;
    @XmlElement
    private String af_status = null;
    @XmlElement
    private String list_card = "";
    @XmlElement
    private String ldap = null;
    @XmlElement
    private String newcard = null;

    /**
     * регистрация через веб с использованием пин
     */
    @XmlElement
    private int uid;
    @XmlElement
    private int reg_source = 21;
    @XmlElement
    private String pass;
    @XmlElement
    private String email;
    @XmlElement
    private String card4 = "";
    @XmlElement
    private String card_pan = "";
    @XmlElement
    private String session;

    private StringBuilder error_msg = new StringBuilder();

    public void initForStep1(int state) {
        this.arm = 30;
        this.state = state;
    }

    public void storeInfo() throws SQLException {
        if(session != null) {
            if ((session).startsWith("unlock-p24-")) {
                reg_source = 22;
            }
        }



            // разблокировка через  веб с использованием пин

        /*reg.addUserActivate(Strings.nullToEmpty(phone),
                Strings.nullToEmpty(inn), ip,
                uid,
                -1,
                Strings.nullToEmpty(list_card),
                "",
                null,
                Strings.nullToEmpty(card_pan).isEmpty() ? card4 : Strings.nullToEmpty(card_pan),
                reg_source,
                Strings.nullToEmpty(error_msg.toString()),
                state, ext_complex_state, arm, clients, ecom_c1, ecom_c2);*/
    }

    public int getEcom_c1() {
        return ecom_c1;
    }

    public void setEcom_c1(int ecom_c1) {
        this.ecom_c1 = ecom_c1;
    }

    public int getEcom_c2() {
        return ecom_c2;
    }

    public void setEcom_c2(int ecom_c2) {
        this.ecom_c2 = ecom_c2;
    }

    public int getClients() {
        return clients;
    }

    public void setClients(int clients) {
        this.clients = clients;
    }

    public int getArm() {
        return arm;
    }

    public void setArm(int arm) {
        this.arm = arm;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public int getExt_complex_state() {
        return ext_complex_state;
    }

    public void setExt_complex_state(int ext_complex_state) {
        this.ext_complex_state = ext_complex_state;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getInn() {
        return inn;
    }

    public void setInn(String inn) {
        this.inn = inn;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getAf_status() {
        return af_status;
    }

    public void setAf_status(String af_status) {
        this.af_status = af_status;
    }

    public String getList_card() {
        return list_card;
    }

    public void setList_card(String list_card) {
        this.list_card = list_card;
    }

    public String getLdap() {
        return ldap;
    }

    public void setLdap(String ldap) {
        this.ldap = ldap;
    }

    public String getNewcard() {
        return newcard;
    }

    public void setNewcard(String newcard) {
        this.newcard = newcard;
    }

    public int getUid() {
        return uid;
    }

    public void setUid(int uid) {
        this.uid = uid;
    }

    public int getReg_source() {
        return reg_source;
    }

    public void setReg_source(int reg_source) {
        this.reg_source = reg_source;
    }

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getCard4() {
        return card4;
    }

    public void setCard4(String card4) {
        this.card4 = card4;
    }

    public String getCard_pan() {
        return card_pan;
    }

    public void setCard_pan(String card_pan) {
        this.card_pan = card_pan;
    }

    public String getSession() {
        return session;
    }

    public void setSession(String session) {
        this.session = session;
    }

    public StringBuilder getError_msg() {
        return error_msg;
    }

    public void setError_msg(StringBuilder error_msg) {
        this.error_msg = error_msg;
    }
}
